package org.vectrics.common.html;

import org.apache.ecs.html.IMG;

public class Table extends org.apache.ecs.html.Table {
	private static final long serialVersionUID = 1652383593762803206L;

	private int rowNumber = 1;
	private String evenCellClass = null;
	private String oddCellClass = null;
	
    public Table() {
        super();
        this.setCellPadding(0);
        this.setCellSpacing(0);
		this.setPrettyPrint(true);
		this.setSummary("Vectrics Table");
    }
    
    public String getEvenCellClass() {
		return evenCellClass;
	}

	public void setEvenCellClass(String evenCellClass) {
		this.evenCellClass = evenCellClass;
	}

	public String getOddCellClass() {
		return oddCellClass;
	}

	public void setOddCellClass(String oddCellClass) {
		this.oddCellClass = oddCellClass;
	}

	public Row addRow()   {
        Row newRow = new Row();
        if (rowNumber % 2 == 0) {
        	newRow.setDefaultCellClass(this.getEvenCellClass());
        } else {
        	newRow.setDefaultCellClass(this.getOddCellClass());
        }
        this.addElement(newRow);
        this.rowNumber++;
        return(newRow);
    }
    
    public Cell addLineRow(String src, int numColumns) {
        Row row = addRow();
        Cell cell = row.addCell();
        cell.setColSpan(numColumns);
        IMG img = new IMG();
        img.setSrc(src);
        img.setHeight(1);
        img.setWidth("100%");
        img.setAlt("");
        cell.addElement(img);
        return(cell);        
    }
   
}
